#include "Button.h"
#include "Tooltip.h"
#include "commctrl.h"

Button::Button()
: m_pTooltip(NULL)
{
	m_hf = CreateFont(15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
}
Button::~Button()
{
	DestroyWindow(m_hWnd);
	if(m_pTooltip)
	{
		delete m_pTooltip;
		m_pTooltip = NULL;
	}
}

bool Button::Setup(HWND a_hWnd, HINSTANCE a_hInst, int a_xPos, int a_yPos, int a_width, int a_height, char* a_label, char* a_pTooltip)
{
	m_hWnd = CreateWindowEx(NULL, "Button", a_label, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_BITMAP, a_xPos, a_yPos, a_width, a_height, a_hWnd, NULL, a_hInst, (LPVOID)this);
	if(m_hWnd == NULL)
	{
		return false;
	}
	m_pTooltip = new Tooltip();
	m_pTooltip->CreateTooltip(m_hWnd, a_pTooltip);

	SendMessage(m_hWnd, WM_SETFONT, (WPARAM)m_hf, (LPARAM)true);	

	UpdateWindow(m_hWnd);
	ShowWindow(m_hWnd, SW_SHOW);

	

	/*HIMAGELIST hImages = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 1, 1);

	HINSTANCE hLib = LoadLibrary("shell32.dll");

	
	//HICON hIcon = (HICON)LoadImage(NULL, "media/water.png", IMAGE_ICON, 0, 0, LR_SHARED | LR_LOADFROMFILE);
	ImageList_AddIcon(hImages, hLib);
	
	FreeLibrary(hLib);

	RECT rect;
	ZeroMemory(&rect, sizeof(RECT));
	BUTTON_IMAGELIST bil;
	bil.himl = hImages;
	bil.margin = rect;
	bil.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
	Button_SetImageList(m_hWnd, &bil);
*/
	return true;
}